
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.5 Pod 升级、回滚 · Kubernetes - 痴者工良</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="痴者工良">
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="6.scale.html" />
    
    
    <link rel="prev" href="4.pod_network.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.whuanle.cn" target="_blank" class="custom-link">痴者工良的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    文档说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    1.基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../1.basic/1.docker.html">
            
                <a href="../1.basic/1.docker.html">
            
                    
                    1.1 说透 Docker：基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../1.basic/2.virtual.html">
            
                <a href="../1.basic/2.virtual.html">
            
                    
                    1.2 说透 Docker： 虚拟化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../1.basic/3.docker_network.html">
            
                <a href="../1.basic/3.docker_network.html">
            
                    
                    1.3 了解 Docker 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../1.basic/4.pod_docker.html">
            
                <a href="../1.basic/4.pod_docker.html">
            
                    
                    1.4 Docker 和 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../1.basic/5.k8s.html">
            
                <a href="../1.basic/5.k8s.html">
            
                    
                    1.5 K8S入门基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../2.deploy/">
            
                <a href="../2.deploy/">
            
                    
                    2.部署和配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../2.deploy/2.deploy.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../2.deploy/1.minikube.html">
            
                <a href="../2.deploy/1.minikube.html">
            
                    
                    2.1 使用 Minikube 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../2.deploy/2.kubeadm.html">
            
                <a href="../2.deploy/2.kubeadm.html">
            
                    
                    2.2 使用 kubeadm 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../2.deploy/3.kubeadm_ckad.html">
            
                <a href="../2.deploy/3.kubeadm_ckad.html">
            
                    
                    2.3 CKAD认证中的部署教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../2.deploy/4.kubeadm_proxy.html">
            
                <a href="../2.deploy/4.kubeadm_proxy.html">
            
                    
                    2.4 国内代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../2.deploy/5.dashboard.html">
            
                <a href="../2.deploy/5.dashboard.html">
            
                    
                    2.5 Dashboard
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    3.Pod部署和调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="./">
            
                <a href="./">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="1.pod.html">
            
                <a href="1.pod.html">
            
                    
                    3.1 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="2.deployment.html">
            
                <a href="2.deployment.html">
            
                    
                    3.2 Deployment部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="3.replica.html">
            
                <a href="3.replica.html">
            
                    
                    3.3 副本集(ReplicaSet)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="4.pod_network.html">
            
                <a href="4.pod_network.html">
            
                    
                    3.34 Pod 端口映射
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.6" data-path="5.update.html">
            
                <a href="5.update.html">
            
                    
                    3.5 Pod 升级、回滚
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="6.scale.html">
            
                <a href="6.scale.html">
            
                    
                    3.6 Pod 缩放
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="7.lable.html">
            
                <a href="7.lable.html">
            
                    
                    3.7.Pod 标签
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="8.schedule.html">
            
                <a href="8.schedule.html">
            
                    
                    3.8 Pod 调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="9.jobs_cronjobs.html">
            
                <a href="9.jobs_cronjobs.html">
            
                    
                    3.9 Jobs、CronJobs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    4.Kubernetes 网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../4.network/1.network.html">
            
                <a href="../4.network/1.network.html">
            
                    
                    4.1 Kubernetes 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../4.network/2.endpoint.html">
            
                <a href="../4.network/2.endpoint.html">
            
                    
                    4.2 Endpoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../4.network/3.ingress.html">
            
                <a href="../4.network/3.ingress.html">
            
                    
                    4.3 ingress
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../4.network/4.discovery.html">
            
                <a href="../4.network/4.discovery.html">
            
                    
                    4.4 服务发现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    5.volumes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../5.volumes/1.volumes.html">
            
                <a href="../5.volumes/1.volumes.html">
            
                    
                    5.1 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../5.volumes/2.secret_configmap.html">
            
                <a href="../5.volumes/2.secret_configmap.html">
            
                    
                    5.2 secret 和 ConfigMap 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../5.volumes/3.nfts.html">
            
                <a href="../5.volumes/3.nfts.html">
            
                    
                    5.3 NFS卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../5.volumes/4.pv_pvc.html">
            
                <a href="../5.volumes/4.pv_pvc.html">
            
                    
                    5.4 持久化卷
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    6.API 和 安全
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../7.health/">
            
                <a href="../7.health/">
            
                    
                    7.维护和故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../8.health/README.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../k8s.html">
            
                <a href="../k8s.html">
            
                    
                    Kubernetes 命令概览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../ckad.html">
            
                <a href="../ckad.html">
            
                    
                    CKAD 认证帮助
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3.5 Pod 升级、回滚</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#35-pod-&#x5347;&#x7EA7;&#x3001;&#x56DE;&#x6EDA;"><b></b>3.5 Pod &#x5347;&#x7EA7;&#x3001;&#x56DE;&#x6EDA;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;"><b></b>&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;</a></li><ul><li><span class="title-icon "></span><a href="#&#x90E8;&#x7F72;&#x5E94;&#x7528;"><b></b>&#x90E8;&#x7F72;&#x5E94;&#x7528;</a></li><li><span class="title-icon "></span><a href="#&#x66F4;&#x65B0;&#x7248;&#x672C;"><b></b>&#x66F4;&#x65B0;&#x7248;&#x672C;</a></li><li><span class="title-icon "></span><a href="#&#x4E0A;&#x7EBF;"><b></b>&#x4E0A;&#x7EBF;</a></li><li><span class="title-icon "></span><a href="#&#x5982;&#x4F55;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;"><b></b>&#x5982;&#x4F55;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;</a></li><li><span class="title-icon "></span><a href="#&#x67E5;&#x770B;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;"><b></b>&#x67E5;&#x770B;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;</a></li><li><span class="title-icon "></span><a href="#&#x56DE;&#x6EDA;"><b></b>&#x56DE;&#x6EDA;</a></li><li><span class="title-icon "></span><a href="#&#x6682;&#x505C;&#x4E0A;&#x7EBF;"><b></b>&#x6682;&#x505C;&#x4E0A;&#x7EBF;</a></li></ul></ul></ul></div><h1 id="35-pod-&#x5347;&#x7EA7;&#x3001;&#x56DE;&#x6EDA;"><a name="35-pod-&#x5347;&#x7EA7;&#x3001;&#x56DE;&#x6EDA;" class="anchor-navigation-ex-anchor" href="#35-pod-&#x5347;&#x7EA7;&#x3001;&#x56DE;&#x6EDA;"><i class="fa fa-link" aria-hidden="true"></i></a>3.5 Pod &#x5347;&#x7EA7;&#x3001;&#x56DE;&#x6EDA;</h1>
<p>&#x672C;&#x7BC7;&#x4E3B;&#x8981;&#x8BA8;&#x8BBA;&#x5982;&#x4F55;&#x5B9E;&#x73B0;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;&#xFF0C;&#x4EFB;&#x610F;&#x66F4;&#x6362;&#x7248;&#x672C;&#x5E76;&#x4E14;&#x56DE;&#x6EDA;&#x4EE5;&#x524D;&#x7684;&#x7248;&#x672C;(&#x7248;&#x672C;&#x66F4;&#x65B0;)&#xFF0C;&#x800C;&#x4E0B;&#x4E00;&#x7AE0;&#x4F1A;&#x8BA8;&#x8BBA;&#x5230; Pod &#x7F29;&#x653E;&#xFF0C;&#x6839;&#x636E;&#x673A;&#x5668;&#x8D44;&#x6E90;&#x81EA;&#x52A8;&#x62D3;&#x5C55;&#x548C;&#x6536;&#x7F29;&#x5E94;&#x7528;(&#x81EA;&#x52A8;&#x6269;&#x5BB9;&#x5B9E;&#x4F8B;)&#x3002;</p>
<h2 id="&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;"><a name="&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;" class="anchor-navigation-ex-anchor" href="#&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;</h2>
<h3 id="&#x90E8;&#x7F72;&#x5E94;&#x7528;"><a name="&#x90E8;&#x7F72;&#x5E94;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x90E8;&#x7F72;&#x5E94;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x90E8;&#x7F72;&#x5E94;&#x7528;</h3>
<p>&#x9996;&#x5148;&#x6211;&#x4EEC;&#x6765;&#x90E8;&#x7F72; nginx&#xFF0C;&#x4F7F;&#x7528; nginx &#x4F5C;&#x4E3A;&#x7EC3;&#x4E60;&#x7684;&#x955C;&#x50CF;&#x3002;</p>
<p>&#x6253;&#x5F00; <a href="https://hub.docker.com/\_/nginx" target="_blank">https://hub.docker.com/_/nginx</a> &#x53EF;&#x4EE5;&#x67E5;&#x8BE2; nginx &#x7684;&#x955C;&#x50CF;&#x7248;&#x672C;&#xFF0C;&#x7B14;&#x8005;&#x8FD9;&#x91CC;&#x9009;&#x62E9;&#x4E09;&#x4E2A;&#x7248;&#x672C;&#xFF1A;<code>1.19.10</code>&#x3001;<code>1.20.0</code>&#x3001;<code>latest</code>&#xFF0C;&#x540E;&#x7EED;&#x6211;&#x4EEC;&#x66F4;&#x65B0;&#x548C;&#x56DE;&#x6EDA;&#x65F6;&#xFF0C;&#x4F1A;&#x5728;&#x8FD9;&#x51E0;&#x4E2A;&#x7248;&#x672C;&#x4E4B;&#x95F4;&#x9009;&#x62E9;&#x3002;</p>
<blockquote>
<p><strong>[Info] &#x63D0;&#x793A;</strong></p>
<p>&#x9700;&#x8981;&#x8BFB;&#x8005;&#x660E;&#x786E;&#x9009;&#x62E9;nginx &#x7684;&#x4E09;&#x4E2A;&#x4E0D;&#x540C;&#x7248;&#x672C;&#xFF0C;&#x6211;&#x4EEC;&#x540E;&#x9762;&#x7684;&#x5347;&#x7EA7;&#x56DE;&#x6EDA;&#x7EC3;&#x4E60;&#x4F1A;&#x5728;&#x8FD9;&#x4E09;&#x4E2A;&#x7248;&#x672C;&#x4E2D;&#x6765;&#x56DE;&#x5207;&#x6362;&#x3002;</p>
<pre class="language-"><code>1.19.10 -&gt; 1.20.0 -&gt; latest
</code></pre></blockquote>
<p>&#x9996;&#x5148;&#xFF0C;&#x6211;&#x4EEC;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Nginx &#x7684; Deployment&#xFF0C;&#x526F;&#x672C;&#x6570;&#x91CF;&#x4E3A; 3&#xFF0C;&#x9996;&#x6B21;&#x90E8;&#x7F72;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8DDF;&#x4E4B;&#x524D;&#x7684;&#x64CD;&#x4F5C;&#x4E00;&#x81F4;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x4EC0;&#x4E48;&#x7279;&#x6B8A;&#x7684;&#x547D;&#x4EE4;&#x3002;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x65E7;&#x4E00;&#x4E9B;&#x7684;&#x7248;&#x672C;&#xFF0C;&#x7B14;&#x8005;&#x4F7F;&#x7528;&#x7684;&#x662F; 1.19.0&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl create deployment nginx --image<span class="token operator">=</span>nginx:1.19.0 --replicas<span class="token operator">=</span><span class="token number">3</span>
<span class="token comment"># &#x6216;&#x8005;</span>
<span class="token comment"># kubectl create deployment nginx --image=nginx:1.19.0 --replicas=3 --record</span>
</code></pre>
<blockquote>
<p><strong>&#x6CE8;&#xFF1A;</strong> &#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x52A0;&#x4E0A; <code>--record</code> &#x6807;&#x5FD7;&#x5C06;&#x6240;&#x6267;&#x884C;&#x7684;&#x547D;&#x4EE4;&#x5199;&#x5165;&#x8D44;&#x6E90;&#x6CE8;&#x89E3; <code>kubernetes.io/change-cause</code> &#x4E2D;&#x3002; &#x8FD9;&#x5BF9;&#x4E8E;&#x4EE5;&#x540E;&#x7684;&#x68C0;&#x67E5;&#x662F;&#x6709;&#x7528;&#x7684;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x8981;&#x67E5;&#x770B;&#x9488;&#x5BF9;&#x6BCF;&#x4E2A; Deployment &#x4FEE;&#x8BA2;&#x7248;&#x672C;&#x6240;&#x6267;&#x884C;&#x8FC7;&#x7684;&#x547D;&#x4EE4;&#xFF0C;&#x5BF9;&#x4E8E;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x4F5C;&#x7528;&#xFF0C;&#x6211;&#x4EEC;&#x540E;&#x9762;&#x518D;&#x89E3;&#x91CA;&#x3002;</p>
</blockquote>
<p>&#x6267;&#x884C; <code>kubectl get pods</code>&#x3001;<code>kubectl describe pods</code>&#x53EF;&#x4EE5;&#x89C2;&#x5BDF;&#x5230;&#x6709;&#x6709;&#x4E09;&#x4E2A; Pod&#xFF0C;&#x6BCF;&#x4E2A; Pod &#x7684; nginx &#x955C;&#x50CF;&#x7248;&#x672C;&#x90FD;&#x662F; 1.19.0&#x3002;</p>
<pre class="language-"><code class="lang-bash">NAME                     READY   STATUS    RESTARTS   AGE
nginx-85b45874d9-7jlrv   <span class="token number">1</span>/1     Running   <span class="token number">0</span>          5s
nginx-85b45874d9-h22xv   <span class="token number">1</span>/1     Running   <span class="token number">0</span>          5s
nginx-85b45874d9-vthfb   <span class="token number">1</span>/1     Running   <span class="token number">0</span>          5s
</code></pre>
<pre class="language-"><code class="lang-bash">Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  119s  default-scheduler  Successfully assigned default/nginx-85b45874d9-vthfb to instance-2
  Normal  Pulled     117s  kubelet            Container image <span class="token string">&quot;nginx:1.19.0&quot;</span> already present on machine
  Normal  Created    117s  kubelet            Created container nginx
  Normal  Started    117s  kubelet            Started container nginx
</code></pre>
<h3 id="&#x66F4;&#x65B0;&#x7248;&#x672C;"><a name="&#x66F4;&#x65B0;&#x7248;&#x672C;" class="anchor-navigation-ex-anchor" href="#&#x66F4;&#x65B0;&#x7248;&#x672C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x66F4;&#x65B0;&#x7248;&#x672C;</h3>
<p>&#x5176;&#x5B9E;&#x66F4;&#x65B0; Pod &#x662F;&#x975E;&#x5E38;&#x7B80;&#x5355;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x9700;&#x8981;&#x63A7;&#x5236;&#x6BCF;&#x4E2A; Pod &#x7684;&#x66F4;&#x65B0;&#xFF0C;&#x4E5F;&#x4E0D;&#x9700;&#x8981;&#x62C5;&#x5FC3;&#x4F1A;&#x4E0D;&#x4F1A;&#x5BF9;&#x4E1A;&#x52A1;&#x4EA7;&#x751F;&#x5F71;&#x54CD;&#xFF0C;K8S &#x4F1A;&#x81EA;&#x52A8;&#x63A7;&#x5236;&#x8FD9;&#x4E9B;&#x8FC7;&#x7A0B;&#x3002;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x89E6;&#x53D1;&#x955C;&#x50CF;<strong>&#x7248;&#x672C;&#x66F4;&#x65B0;&#x4E8B;&#x4EF6;</strong>&#xFF0C;K8S &#x4F1A;&#x81EA;&#x52A8;&#x4E3A;&#x6211;&#x4EEC;&#x66F4;&#x65B0;&#x6240;&#x6709; Pod &#x7684;&#x3002;</p>
<p><code>kubectl set image</code> &#x53EF;&#x4EE5;&#x66F4;&#x65B0;&#x73B0;&#x6709;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x7684;&#x5BB9;&#x5668;&#x955C;&#x50CF;&#xFF0C;&#x5BF9;&#x8C61;&#x5305;&#x62EC; <code>Pod</code>&#x3001;<code>Deployment</code>&#x3001;<code>DaemonSet</code>&#x3001;<code>Job</code>&#x3001;<code>ReplicaSet</code>&#x3002;&#x5728;&#x66F4;&#x65B0;&#x7248;&#x672C;&#x4E2D;&#xFF0C;&#x5355;&#x4E2A;&#x5BB9;&#x5668;&#x7684; Pod&#xFF0C;&#x5BF9;&#x4E8E;&#x591A;&#x4E2A;&#x5BB9;&#x5668;&#x7684; Pod &#x884C;&#x4E3A;&#x662F;&#x5DEE;&#x4E0D;&#x591A;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x5355;&#x5BB9;&#x5668; Pod &#x7EC3;&#x4E60;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x66F4;&#x65B0; Deployment &#x4E2D;&#x7684;&#x955C;&#x50CF;&#x7248;&#x672C;&#xFF0C;&#x89E6;&#x53D1; Pod&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl <span class="token builtin class-name">set</span> image deployment nginx <span class="token assign-left variable">nginx</span><span class="token operator">=</span>nginx:1.20.0
</code></pre>
<p>&#x683C;&#x5F0F;&#x4E3A;&#xFF1A;</p>
<pre class="language-"><code>kubectl set image deployment {deployment&#x540D;&#x79F0;} {&#x955C;&#x50CF;&#x540D;&#x79F0;}:={&#x955C;&#x50CF;&#x540D;&#x79F0;}:{&#x7248;&#x672C;}
</code></pre><blockquote>
<p>&#x6B64;&#x547D;&#x4EE4;&#x53EF;&#x4EE5;&#x4EFB;&#x610F;&#x4FEE;&#x6539; Pod &#x4E2D;&#x7684;&#x5176;&#x4E2D;&#x4E00;&#x4E2A;&#x5BB9;&#x5668;&#x7684;&#x7248;&#x672C;&#xFF0C;&#x53EA;&#x8981;&#x67D0;&#x4E2A;&#x5BB9;&#x5668;&#x7684;&#x955C;&#x50CF;&#x7248;&#x672C;&#x53D8;&#x5316;&#xFF0C;&#x6574;&#x4E2A; Pod &#x90FD;&#x4F1A;&#x91CD;&#x65B0;&#x90E8;&#x7F72;&#x3002;&#x5982;&#x679C;&#x955C;&#x50CF;&#x7248;&#x672C;&#x6CA1;&#x6709;&#x53D8;&#x5316;&#xFF0C;&#x5373;&#x4F7F;&#x662F;&#x6267;&#x884C;&#x4E86; <code>kubectl set image</code> &#xFF0C;&#x4E5F;&#x4E0D;&#x4F1A;&#x4EA7;&#x751F;&#x5F71;&#x54CD;&#x3002;</p>
</blockquote>
<div class="mermaid">
gantt
dateFormat  YYYY-MM-DD
title Nginx image update
excludes weekdays 2021-11-04

section Nginx
Nginx 1.19.0          :done  , 2021-11-05, 1d
Nginx 1.20.0          :active, 2021-11-06, 1d
</div>



<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x67E5;&#x770B; Pod &#x7684;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl describe pods
</code></pre>
<p>&#x627E;&#x5230; Events &#x63CF;&#x8FF0;&#xFF1A;</p>
<pre class="language-"><code>... ...
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  66s   default-scheduler  Successfully assigned default/nginx-7b87485749-rlmcx to instance-2
  Normal  Pulled     66s   kubelet            Container image &quot;nginx:1.20.0&quot; already present on machine
  Normal  Created    66s   kubelet            Created container nginx
  Normal  Started    65s   kubelet            Started container nginx
</code></pre><p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x73B0;&#x5728;&#x73B0;&#x5728;&#x521B;&#x5EFA;&#x7684; Pod &#x5B9E;&#x4F8B;&#x4E3A; 1.20.0 &#x7248;&#x672C;&#x3002;</p>
<blockquote>
<p>&#x66F4;&#x65B0;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x4F1A;&#x521B;&#x5EFA;&#x65B0;&#x7248;&#x672C;&#x7684; Pod&#xFF0C;&#x65E7;&#x7684; Pod &#x4F1A;&#x88AB;&#x9010;&#x6E10;&#x79FB;&#x9664;&#x3002;</p>
</blockquote>
<p>&#x6211;&#x4EEC;&#x5728;&#x521B;&#x5EFA; Deployment &#x65F6;&#xFF0C;&#x751F;&#x6210;&#x4E86;&#x4E09;&#x4E2A; Pod &#xFF0C;&#x800C;&#x5F53;&#x6211;&#x4EEC;&#x89E6;&#x53D1;&#x955C;&#x50CF;&#x7248;&#x672C;&#x66F4;&#x65B0;&#x65F6;&#xFF0C;Pod &#x4E0D;&#x4F1A;&#x4E00;&#x6B21;&#x6027;&#x66F4;&#x65B0;&#xFF0C;&#x800C;&#x662F;&#x6309;&#x7167;&#x4E00;&#x5B9A;&#x89C4;&#x5219;&#x6BCF;&#x6B21;&#x53EA;&#x91CD;&#x65B0;&#x90E8;&#x7F72;&#x4E00;&#x90E8;&#x5206; Pod&#xFF0C;Pod &#x66F4;&#x65B0;&#x66FF;&#x6362;&#x8FC7;&#x7A0B;&#x7C7B;&#x4F3C;&#x4E0B;&#x56FE;&#x6240;&#x793A;(&#x5B9E;&#x9645;&#x4E0A; Pod &#x6570;&#x91CF;&#x53EF;&#x80FD;&#x5927;&#x4E8E; 3&#x4E2A;)&#xFF1A;</p>
<p><img src="images/pod&#x66F4;&#x65B0;&#x66FF;&#x6362;&#x8FC7;&#x7A0B;.png" alt="pod&#x66F4;&#x65B0;&#x66FF;&#x6362;&#x8FC7;&#x7A0B;"></p>
<p>&#x53E6;&#x5916;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; <code>kubectl edit yaml</code> &#x7684;&#x65B9;&#x5F0F;&#x65B9;&#x5F0F;&#x66F4;&#x65B0; Pod&#x3002;</p>
<p>&#x6267;&#x884C;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl edit deployment nginx
</code></pre>
<p>&#x7136;&#x540E;&#x4F1A;&#x5F39;&#x51FA;&#x7F16;&#x8F91; YAML &#x7684;&#x754C;&#x9762;&#xFF0C;&#x5C06; <code>.spec.template.spec.containers[0].image</code> &#x4ECE; <code>nginx:1.19.0</code> &#x66F4;&#x6539;&#x81F3; <code>nginx:1.20.0</code>&#xFF0C;&#x7136;&#x540E;&#x4FDD;&#x5B58;&#x5373;&#x53EF;&#x3002;</p>
<blockquote>
<p>&#x4E3A;&#x4E86;&#x8BB0;&#x5F55;&#x7248;&#x672C;&#x66F4;&#x65B0;&#x4FE1;&#x606F;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5728; <code>kubectl create deployment</code>&#x3001;<code>kubectl set image</code> &#x547D;&#x4EE4;&#x540E;&#x9762;&#x52A0;&#x4E0A; <code>--record</code>&#x3002;</p>
<p>&#x522B;&#x5FD8;&#x8BB0;&#x4E86; <code>kubectl scale</code> &#x547D;&#x4EE4;&#x4E5F;&#x53EF;&#x4EE5;&#x66F4;&#x6539;&#x526F;&#x672C;&#x6570;&#x91CF;&#x3002;</p>
</blockquote>
<h3 id="&#x4E0A;&#x7EBF;"><a name="&#x4E0A;&#x7EBF;" class="anchor-navigation-ex-anchor" href="#&#x4E0A;&#x7EBF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E0A;&#x7EBF;</h3>
<p>&#x4EC5;&#x5F53; Deployment Pod &#x6A21;&#x677F;&#xFF08;&#x5373; <code>.spec.template</code>&#xFF09;&#x53D1;&#x751F;&#x6539;&#x53D8;&#x65F6;&#xFF0C;&#x4F8B;&#x5982;&#x6A21;&#x677F;&#x7684;&#x6807;&#x7B7E;&#x6216;&#x5BB9;&#x5668;&#x955C;&#x50CF;&#x88AB;&#x66F4;&#x65B0;&#xFF0C; &#x624D;&#x4F1A;&#x89E6;&#x53D1; Deployment &#x4E0A;&#x7EBF;&#x3002;</p>
<p>&#x5176;&#x4ED6;&#x66F4;&#x65B0;&#xFF08;&#x5982;&#x5BF9; Deployment &#x6267;&#x884C;&#x6269;&#x7F29;&#x5BB9;&#x7684;&#x64CD;&#x4F5C;&#xFF09;&#x4E0D;&#x4F1A;&#x89E6;&#x53D1;&#x4E0A;&#x7EBF;&#x52A8;&#x4F5C;&#xFF0C;Deployment &#x7684;&#x4E0A;&#x7EBF;&#x52A8;&#x4F5C;&#x53EF;&#x4EE5;&#x4E3A;&#x6211;&#x4EEC;&#x66F4;&#x65B0; Pod &#x7684;&#x7248;&#x672C;(Pod &#x4E2D;&#x7684;&#x5BB9;&#x5668;&#x7248;&#x672C;)&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x63D0;&#x5230;&#x7684; &#x4E0A;&#x7EBF;/&#x66F4;&#x65B0;&#x7248;&#x672C; &#x662F;&#x56E0;&#x4E3A;&#x5BB9;&#x5668;&#x7248;&#x672C;&#x4F1A;&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF0C;&#x800C;&#x66F4;&#x65B0;&#x4E00;&#x822C;&#x6307;&#x4FEE;&#x6539;&#x4E86; YAML &#x7B49;&#xFF0C;&#x4E0D;&#x4E00;&#x5B9A;&#x4F1A;&#x5BF9;&#x5BB9;&#x5668;&#x4EA7;&#x751F;&#x5F71;&#x54CD;&#x3002;</p>
<p>&#x5F53;&#x6211;&#x4EEC;&#x66F4;&#x65B0; Pod &#x7248;&#x672C;&#x65F6;&#xFF0C;K8S &#x4F1A;&#x81EA;&#x52A8;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x628A;&#x6240;&#x6709; pod &#x5220;&#x9664;&#xFF0C;&#x518D;&#x91CD;&#x65B0;&#x521B;&#x5EFA;&#x65B0;&#x7248;&#x672C; Pod&#xFF0C;<strong>&#x5B83;&#x4F1A;&#x4EE5;&#x7A33;&#x5065;&#x7684;&#x65B9;&#x5F0F;&#x9010;&#x6E10;&#x66FF;&#x6362; Pod &#x526F;&#x672C;</strong>&#xFF0C;&#x6240;&#x4EE5;&#x53EB;<strong>&#x6EDA;&#x52A8;&#x66F4;&#x65B0;</strong>&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; <code>kubectl rollout status</code> &#x547D;&#x4EE4;&#xFF0C;&#x67E5;&#x770B; Pod &#x7684;&#x4E0A;&#x7EBF;&#x72B6;&#x6001;&#xFF0C;&#x5373; Pod &#x526F;&#x672C;&#x96C6;&#x7684;&#x66F4;&#x66FF;&#x72B6;&#x6001;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl rollout status deployment nginx
</code></pre>
<p>&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x4E00;&#x822C;&#x6709;&#x4E24;&#x79CD;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment"># &#x5DF2;&#x7ECF;&#x5B8C;&#x6210;&#x65F6;&#xFF1A;</span>
deployment <span class="token string">&quot;nginx-deployment&quot;</span> successfully rolled out
<span class="token comment"># &#x8FD8;&#x5728;&#x66F4;&#x65B0;&#x65F6;&#xFF1A;</span>
Waiting <span class="token keyword">for</span> rollout to finish: <span class="token number">2</span> out of <span class="token number">3</span> new replicas have been updated<span class="token punctuation">..</span>.
</code></pre>
<p>&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x83B7;&#x53D6; Deployment &#x4FE1;&#x606F;&#x65F6;&#xFF0C;&#x67E5;&#x770B;&#x5DF2;&#x66F4;&#x65B0;&#x7684; pod &#x6570;&#x91CF;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl get deployment
</code></pre>
<pre class="language-"><code class="lang-bash">NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   <span class="token number">3</span>/3     <span class="token number">3</span>            <span class="token number">3</span>           18m
</code></pre>
<p>UP-TO-DATE &#x5B57;&#x6BB5;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6210;&#x529F;&#x66F4;&#x65B0;&#x7684; pod &#x6570;&#x91CF;&#x3002;</p>
<p>&#x8FD8;&#x53EF;&#x4EE5;&#x67E5;&#x770B; ReplicaSet &#x548C; Pod&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl get replicaset
kubectl get pods
</code></pre>
<p>&#x8F93;&#x51FA;&#x7C7B;&#x578B;&#x4E8E;&#xFF1A;</p>
<pre class="language-"><code>NAME               DESIRED   CURRENT   READY   AGE
nginx-7b87485749   0         0         0       20m
nginx-85b45874d9   3         3         3       21m
</code></pre><pre class="language-"><code>NAME                     READY   STATUS    RESTARTS   AGE
nginx-85b45874d9-nrbg8   1/1     Running   0          12m
nginx-85b45874d9-qc7f2   1/1     Running   0          12m
nginx-85b45874d9-t48vw   1/1     Running   0          12m
</code></pre><p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6709;&#x4E24;&#x4E2A; ReplicaSet&#xFF0C;nginx-7b87485749 &#x662F; 1.19.0 &#x7248;&#x672C;&#xFF0C;&#x5DF2;&#x7ECF;&#x88AB;&#x5168;&#x90E8;&#x66F4;&#x65B0;&#x5230; 1.20.0 &#x7248;&#x672C; &#x4E86;&#xFF0C;&#x6240;&#x4EE5;&#x524D;&#x8005;&#x7684;&#x6570;&#x91CF;&#x4E3A; 0&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x770B;&#x5230; Pod &#x4E2D;&#xFF0C;&#x6240;&#x6709; Pod &#x90FD;&#x662F;&#x4EE5; <code>nginx-85b45874d9</code> &#x4F5C;&#x4E3A;&#x524D;&#x7F00;&#x7684;&#x3002;&#x8FD9;&#x51E0;&#x4E2A;&#x5173;&#x952E;&#x4FE1;&#x606F;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x622A;&#x56FE;&#xFF0C;&#x540E;&#x9762;&#x518D;&#x6B21;&#x5BF9;&#x7167;&#x3002;</p>
<h3 id="&#x5982;&#x4F55;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;"><a name="&#x5982;&#x4F55;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;" class="anchor-navigation-ex-anchor" href="#&#x5982;&#x4F55;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5982;&#x4F55;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;</h3>
<p>&#x6211;&#x4EEC;&#x66F4;&#x65B0; &#x955C;&#x50CF;&#x7248;&#x672C;&#x65F6;&#xFF0C;&#x65E7;&#x7684; Pod &#x7248;&#x672C;&#x4F1A;&#x88AB;&#x66FF;&#x6362;&#xFF0C;&#x4F46;&#x662F; ReplicaSet &#x526F;&#x672C;&#x8BB0;&#x5F55;&#x662F;&#x4E0D;&#x4F1A;&#x88AB;&#x5220;&#x9664;&#x7684;&#x3002;&#x5B9E;&#x9645;&#x4E0A;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x5C31;&#x662F;&#x63A7;&#x5236;&#x526F;&#x672C;&#x6570;&#x91CF;&#xFF0C;&#x539F;&#x672C; 1.19.0 &#x7684;&#x526F;&#x672C;&#x6570;&#x91CF;&#x4E3A; 3&#xFF0C;&#x73B0;&#x5728;&#x53D8;&#x6210; 0&#xFF0C;1.20.0 &#x7684;&#x526F;&#x672C;&#x6570;&#x91CF;&#x53D8;&#x6210; 3 &#x3002;</p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#x4E0A;&#x7EBF;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x66F4;&#x65B0;&#x8F6F;&#x4EF6;&#x7248;&#x672C;&#xFF0C;&#x5982;&#x679C;&#x4E00;&#x6B21;&#x6027;&#x66F4;&#x65B0;&#x6240;&#x6709;&#x5BB9;&#x5668;&#x6216;&#x8005; pod&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x7684;&#x8F6F;&#x4EF6;&#x4F1A;&#x6709;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#x5904;&#x4E8E;&#x4E0D;&#x53EF;&#x7528;&#x72B6;&#x6001;&#xFF0C;&#x76F4;&#x5230;&#x6240;&#x6709; Pod &#x90FD;&#x5B8C;&#x6210;&#x66F4;&#x65B0;&#x3002;</p>
<p>Deployment &#x53EF;&#x786E;&#x4FDD;&#x5728;&#x66F4;&#x65B0;&#x65F6;&#x4EC5;&#x5173;&#x95ED;&#x4E00;&#x5B9A;&#x6570;&#x91CF;&#x7684; Pod&#xFF0C;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5B83;&#x786E;&#x4FDD;&#x81F3;&#x5C11;&#x6240;&#x9700; Pods 75% &#x5904;&#x4E8E;&#x8FD0;&#x884C;&#x72B6;&#x6001;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6B63;&#x5728;&#x88AB;&#x66F4;&#x65B0;&#x7684; Pod &#x6BD4;&#x4F8B;&#x4E0D;&#x8D85;&#x8FC7; 25%&#x3002;&#x5F53;&#x7136;&#xFF0C;&#x53EA;&#x6709;&#x4E24;&#x4E09;&#x4E2A; pod &#x7684; Deployment &#x4E0D;&#x4F1A;&#x6309;&#x7167;&#x8FD9;&#x4E2A;&#x6BD4;&#x4F8B;&#x9650;&#x5B9A;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;Deployment &#x7B49;&#x5904;&#x4E8E;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x72B6;&#x6001;&#x65F6;&#xFF0C;&#x5176;&#x59CB;&#x7EC8;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x6709;&#x53EF;&#x7528;&#x7684; Pod &#x63D0;&#x4F9B;&#x670D;&#x52A1;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x7684; Pod &#x6570;&#x91CF;&#x8DB3;&#x591F;&#x5927;&#xFF0C;&#x6216;&#x8005;&#x5728;&#x66F4;&#x65B0; Deployment &#x65F6;&#x8FC5;&#x901F;&#x8F93;&#x51FA;&#x4E0A;&#x7EBF;&#x72B6;&#x6001;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x65B0;&#x65E7;&#x7684; Pod &#x6570;&#x91CF;&#x52A0;&#x8D77;&#x6765;&#x4E0D;&#x4E00;&#x5B9A;&#x5C31;&#x662F; 3 &#x4E2A;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x4E0D;&#x4F1A;&#x6740;&#x6B7B;&#x8001; Pods&#xFF0C;&#x76F4;&#x5230;&#x6709;&#x8DB3;&#x591F;&#x7684;&#x6570;&#x91CF;&#x65B0;&#x7684; Pods &#x5DF2;&#x7ECF;&#x51FA;&#x73B0;&#x3002; &#x5728;&#x8DB3;&#x591F;&#x6570;&#x91CF;&#x7684;&#x65E7; Pods &#x88AB;&#x6740;&#x6B7B;&#x524D;&#x5E76;&#x6CA1;&#x6709;&#x521B;&#x5EFA;&#x65B0; Pods&#x3002;&#x5F53;&#x526F;&#x672C;&#x6570;&#x91CF;&#x4E3A;3&#x4E2A;&#x65F6;&#xFF0C;&#x5B83;&#x786E;&#x4FDD;&#x81F3;&#x5C11; 2 &#x4E2A; Pod &#x53EF;&#x7528;&#xFF0C;&#x540C;&#x65F6; &#x6700;&#x591A;&#x603B;&#x5171; 4 &#x4E2A; Pod &#x5B58;&#x5728;(&#x4E0D;&#x540C;&#x7248;&#x672C;)&#x3002;</p>
<p><img src="images/&#x65B0;&#x65E7;pod.png" alt="&#x65B0;&#x65E7;pod"></p>
<p>&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x8FC7;&#x7A0B;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="images/&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x8FC7;&#x7A0B;.png" alt="&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x8FC7;&#x7A0B;"></p>
<p>Deployment &#x786E;&#x4FDD;&#x4EC5;&#x6240;&#x521B;&#x5EFA; Pod &#x6570;&#x91CF;&#x53EA;&#x53EF;&#x80FD;&#x6BD4;&#x671F;&#x671B; Pods &#x6570;&#x9AD8;&#x4E00;&#x70B9;&#x70B9;&#x3002; &#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5B83;&#x53EF;&#x786E;&#x4FDD;&#x542F;&#x52A8;&#x7684; Pod &#x4E2A;&#x6570;&#x6BD4;&#x671F;&#x671B;&#x4E2A;&#x6570;&#x6700;&#x591A;&#x591A;&#x51FA; 25%&#xFF08;&#x6700;&#x5927;&#x5CF0;&#x503C; 25%&#xFF09;&#x6240;&#x4EE5;&#x5728;&#x81EA;&#x52A8;&#x66F4;&#x65B0; Deployment &#x65F6;&#xFF0C;&#x89C2;&#x5BDF;&#x5230;&#x7684; pod &#x53EF;&#x80FD;&#x4E3A; 4&#x4E2A;&#xFF0C;&#x8FD9;&#x662F;&#x7531; Deployment &#x7684;&#x7F29;&#x653E;&#x914D;&#x7F6E;&#x51B3;&#x5B9A;&#x7684;(&#x4E0B;&#x4E00;&#x7AE0;&#x8BB2;&#x89E3;)&#x3002;&#x53E6;&#x5916;&#xFF0C;&#x5728; Deployment &#x66F4;&#x65B0;&#x65F6;&#xFF0C;&#x9664;&#x4E86;&#x53EF;&#x4EE5;&#x66F4;&#x6539;&#x955C;&#x50CF;&#x7684;&#x7248;&#x672C;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x66F4;&#x6539; ReplicaSet &#x7684;&#x6570;&#x91CF;&#x3002;</p>
<p>&#x6267;&#x884C; <code>kubectl describe deployment nginx</code> &#x67E5;&#x770B; Deployment &#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#xFF0C;&#x6211;&#x4EEC;&#x67E5;&#x770B; Event &#x5B57;&#x6BB5;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x89C2;&#x5BDF;&#x5230;&#x65B0;&#x65E7; Pod &#x7684;&#x66F4;&#x66FF;&#x8FC7;&#x7A0B;&#x3002;</p>
<p><img src="../.gitbook/assets/&#x65B0;&#x65E7;pod&#x521B;&#x5EFA;&#x8FC7;&#x7A0B;.png" alt="&#x65B0;&#x65E7;pod&#x521B;&#x5EFA;&#x8FC7;&#x7A0B;"></p>
<p>&#x4F46;&#x662F;&#x8FD9;&#x4E9B;&#x539F;&#x7406;&#x7B49;&#x77E5;&#x8BC6;&#x6211;&#x4EEC;&#x90FD;&#x4E0D;&#x9700;&#x8981;&#x8BB0;&#xFF0C;&#x4E5F;&#x4E0D;&#x9700;&#x8981;&#x6DF1;&#x5165;&#xFF0C;&#x6211;&#x4EEC;&#x8BB0;&#x5F97;&#x6709;&#x8FD9;&#x56DE;&#x4E8B;&#x5C31;&#x884C;&#xFF0C;&#x6709;&#x9700;&#x8981;&#x7684;&#x65F6;&#x5019;&#x4E5F;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x67E5;&#x770B;&#x6587;&#x6863;&#x7684;&#xFF0C;&#x540E;&#x9762;&#x7684;&#x7AE0;&#x8282;&#x8FD8;&#x4F1A;&#x8BE6;&#x7EC6;&#x4ECB;&#x7ECD; ReplicaSet &#x7684;&#x89C4;&#x5219;&#x3002;</p>
<h3 id="&#x67E5;&#x770B;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;"><a name="&#x67E5;&#x770B;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;" class="anchor-navigation-ex-anchor" href="#&#x67E5;&#x770B;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x67E5;&#x770B;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;</h3>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C; Deployment &#x7684;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;&#x90FD;&#x4F1A;&#x4FDD;&#x7559;&#x5728;&#x7CFB;&#x7EDF;&#x4E2D;&#xFF0C;&#x4EE5;&#x4FBF;&#x53EF;&#x4EE5;&#x968F;&#x65F6;&#x56DE;&#x6EDA;&#xFF0C;&#x524D;&#x9762;&#x6211;&#x4EEC;&#x4E5F;&#x63D0;&#x5230;&#x4E86;&#x67E5;&#x770B; <code>kubectl get replicasets</code> &#x65F6;&#x51FA;&#x73B0;&#x7684;&#x526F;&#x672C;&#x8BB0;&#x5F55;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x67E5;&#x770B; Deployment &#x7684;&#x4E0A;&#x7EBF;&#x5386;&#x53F2;&#x8BB0;&#x5F55;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl rollout <span class="token function">history</span> deployment nginx
</code></pre>
<pre class="language-"><code class="lang-bash">REVISION  CHANGE-CAUSE
<span class="token number">1</span>         <span class="token operator">&lt;</span>none<span class="token operator">&gt;</span>
<span class="token number">2</span>         <span class="token operator">&lt;</span>none<span class="token operator">&gt;</span>

<span class="token comment"># &#x5E26; --record &#x7684;&#x8BDD;&#xFF0C;&#x8F93;&#x51FA;&#x662F;</span>
REVISION  CHANGE-CAUSE
<span class="token number">2</span>       kubectl <span class="token builtin class-name">set</span> image deployment nginx <span class="token assign-left variable">nginx</span><span class="token operator">=</span>nginx:1.20.0 --record<span class="token operator">=</span>true
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6709;&#x4E24;&#x4E2A;&#x7248;&#x672C;&#xFF0C;&#x4F46;&#x662F;<code>CHANGE-CAUSE</code> &#x4E3A; <code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span></code> &#x5462;&#xFF1F;&#x8FD9;&#x662F;&#x56E0;&#x4E3A;&#x7B14;&#x8005;&#x6CA1;&#x6709;&#x4F7F;&#x7528; <code>--record</code> &#x53C2;&#x6570;&#x8BB0;&#x5F55;&#x4FE1;&#x606F;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x5E26;&#x4E0A; <code>--record</code> &#x7684;&#x8BDD;&#xFF0C;&#x6211;&#x4EEC;&#x770B;&#x7740;&#x8FD9;&#x4E2A;&#x5386;&#x53F2;&#x8BB0;&#x5F55;&#xFF0C;&#x5B8C;&#x5168;&#x5206;&#x4E0D;&#x51FA;&#x5230;&#x5E95;&#x662F;&#x4EC0;&#x4E48;&#x7248;&#x672C;&#x3002;</p>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x67E5;&#x770B; &#x7248;&#x672C;2 &#x7684;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre class="language-"><code>kubectl rollout history deployment nginx --revision=2
</code></pre><pre class="language-"><code class="lang-yaml">deployment.apps/nginx with revision <span class="token comment">#2</span>
<span class="token key atrule">Pod Template</span><span class="token punctuation">:</span>
  <span class="token key atrule">Labels</span><span class="token punctuation">:</span>    app=nginx
    pod<span class="token punctuation">-</span>template<span class="token punctuation">-</span>hash=85b45874d9
  <span class="token key atrule">Containers</span><span class="token punctuation">:</span>
   <span class="token key atrule">nginx</span><span class="token punctuation">:</span>
    <span class="token key atrule">Image</span><span class="token punctuation">:</span>    nginx<span class="token punctuation">:</span>1.20.0
    <span class="token key atrule">Port</span><span class="token punctuation">:</span>    &lt;none<span class="token punctuation">&gt;</span>
    <span class="token key atrule">Host Port</span><span class="token punctuation">:</span>    &lt;none<span class="token punctuation">&gt;</span>
    <span class="token key atrule">Environment</span><span class="token punctuation">:</span>    &lt;none<span class="token punctuation">&gt;</span>
    <span class="token key atrule">Mounts</span><span class="token punctuation">:</span>    &lt;none<span class="token punctuation">&gt;</span>
  <span class="token key atrule">Volumes</span><span class="token punctuation">:</span>    &lt;none<span class="token punctuation">&gt;</span>
</code></pre>
<h3 id="&#x56DE;&#x6EDA;"><a name="&#x56DE;&#x6EDA;" class="anchor-navigation-ex-anchor" href="#&#x56DE;&#x6EDA;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x56DE;&#x6EDA;</h3>
<p>&#x5F53;&#x90E8;&#x7F72;&#x7684;&#x65B0;&#x7248;&#x672C;&#x7A0B;&#x5E8F;&#x53D1;&#x73B0;&#x4E25;&#x91CD; bug &#x5F71;&#x54CD;&#x5E73;&#x53F0;&#x7A33;&#x5B9A;&#x6027;&#x65F6;&#xFF0C;&#x4F60;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x5C06;&#x9879;&#x76EE;&#x5207;&#x6362;&#x4E3A;&#x4E0A;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#x3002;&#x76EE;&#x524D;&#x4ECB;&#x7ECD;&#x4E86;&#x51E0;&#x4E2A;&#x67E5;&#x770B; Deployment &#x4E0A;&#x7EBF;&#x7684;&#x5386;&#x53F2;&#x8BB0;&#x5F55;&#x7684;&#x547D;&#x4EE4;&#xFF0C;&#x4E0B;&#x9762;&#x4ECB;&#x7ECD;&#x5982;&#x679C;&#x5C06; Pod &#x6362;&#x5230;&#x65E7;&#x7684;&#x7248;&#x672C;&#x3002;</p>
<p>&#x56DE;&#x6EDA;&#x5230;&#x4E0A;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#x7684;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">root@master:~<span class="token comment"># kubectl rollout undo deployment nginx</span>
deployment.apps/nginx rolled back
</code></pre>
<blockquote>
<p>&#x4F8B;&#x5982;&#x5F53;&#x524D;&#x662F; &#x7248;&#x672C;2&#xFF0C;&#x90A3;&#x4E48;&#x4F1A;&#x56DE;&#x6EDA;&#x5230; &#x7248;&#x672C;1&#x3002;</p>
</blockquote>
<p>&#x518D;&#x6267;&#x884C; <code>kubectl rollout history deployment nginx</code> &#x4F1A;&#x53D1;&#x73B0; revision &#x53D8;&#x6210; 3 &#x4E86;&#x3002;</p>
<pre class="language-"><code class="lang-bash">root@master:~<span class="token comment"># kubectl rollout history deployment nginx</span>
deployment.apps/nginx 
REVISION  CHANGE-CAUSE
<span class="token number">2</span>         <span class="token operator">&lt;</span>none<span class="token operator">&gt;</span>
<span class="token number">3</span>         <span class="token operator">&lt;</span>none<span class="token operator">&gt;</span>
</code></pre>
<blockquote>
<p>revision &#x8BB0;&#x5F55;&#x7684;&#x662F;&#x90E8;&#x7F72;&#x8BB0;&#x5F55;&#xFF0C;&#x4E0E; Pod &#x7684;&#x955C;&#x50CF;&#x7248;&#x672C;&#x65E0;&#x5173;&#xFF0C;&#x6BCF;&#x6B21;&#x66F4;&#x65B0;&#x7248;&#x672C;&#x6216;&#x8FDB;&#x884C;&#x56DE;&#x6EDA;&#x7B49;&#x64CD;&#x4F5C;&#x65F6;&#xFF0C; revision &#x4F1A;&#x81EA;&#x52A8;&#x9012;&#x589E; 1&#x3002;</p>
</blockquote>
<p>&#x5982;&#x679C;&#x7248;&#x672C;&#x6570;&#x91CF;&#x591A;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x56DE;&#x6EDA;&#x5230;&#x7279;&#x70B9;&#x7684;&#x7248;&#x672C;&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl rollout undo deployment nginx --to-revision<span class="token operator">=</span><span class="token number">2</span>
</code></pre>
<p>&#x8FD9;&#x91CC;&#x63D0;&#x4E00;&#x4E0B; <code>--record</code>&#xFF0C;&#x5728;&#x524D;&#x9762;&#xFF0C;&#x6211;&#x4EEC;&#x521B;&#x5EFA;&#x548C;&#x66F4;&#x65B0; Deployment &#x65F6;&#xFF0C;&#x90FD;&#x6CA1;&#x6709;&#x4F7F;&#x7528;&#x5230;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5176;&#x5B9E;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x5F88;&#x6709;&#x7528;&#x7684;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x6BCF;&#x6B21;&#x6267;&#x884C;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x65F6;&#x90FD;&#x8981;&#x5E26;&#x4E0A;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x624D;&#x884C;&#x3002;</p>
<p>&#x66F4;&#x65B0;&#x955C;&#x50CF;&#x5230;&#x6307;&#x5B9A;&#x7248;&#x672C;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl <span class="token builtin class-name">set</span> image deployment nginx <span class="token assign-left variable">nginx</span><span class="token operator">=</span>nginx:1.19.0 --record
</code></pre>
<pre class="language-"><code>kubectl rollout history deployment nginx
</code></pre><p>&#x8F93;&#x51FA;&#xFF1A;</p>
<pre class="language-"><code>REVISION  CHANGE-CAUSE
5         <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span>
6         kubectl set image deployment nginx nginx=nginx:1.19.0 --record=true
</code></pre><p>&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x8FD9;&#x91CC;&#x76EE;&#x524D;&#x6765;&#x8BF4;&#xFF0C;&#x53EA;&#x6709;&#x4E24;&#x4E2A;&#x8BB0;&#x5F55;&#xFF0C;&#x6211;&#x4EEC;&#x660E;&#x660E;&#x63D0;&#x4EA4;&#x4E86;&#x591A;&#x6B21;&#xFF0C;&#x867D;&#x7136; revision &#x4F1A;&#x53D8;&#x5316;&#xFF0C;&#x4F46;&#x662F;&#x8FD9;&#x91CC;&#x67E5;&#x8BE2;&#x7684;&#x53EA;&#x6709;&#x4E24;&#x6761;&#x8BB0;&#x5F55;&#xFF0C;&#x8FD9;&#x65F6;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x64CD;&#x4F5C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EA;&#x7528;&#x5230;&#x4E86; 1.19.0&#x3001;1.20.0 &#x4E24;&#x4E2A;&#x7248;&#x672C;&#xFF0C;&#x6240;&#x4EE5;&#x4E5F;&#x5C31;&#x53EA;&#x6709;&#x8FD9;&#x4E24;&#x4E2A;&#x7248;&#x672C;&#x7684;&#x63D0;&#x4EA4;&#x8BB0;&#x5F55;&#x3002;&#x591A;&#x7528;&#x51E0;&#x4E2A;&#x7248;&#x672C;&#xFF0C;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre class="language-"><code>REVISION  CHANGE-CAUSE
7         kubectl set image deployment nginx nginx=nginx:1.19.0 --record=true
8         kubectl set image deployment nginx nginx=nginx:1.20.0 --record=true
9         kubectl set image deployment nginx nginx=nginx:latest --record=true
</code></pre><p>REVISION &#x5B57;&#x6BB5;&#x7684;&#x6570;&#x5B57;&#x662F;&#x4F1A;&#x9012;&#x589E;&#x7684;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x89E6;&#x53D1;&#x4E0A;&#x7EBF;&#x52A8;&#x4F5C;(&#x5BB9;&#x5668;&#x6807;&#x7B7E;&#x3001;&#x7248;&#x672C;&#x7B49;)&#x65F6;&#xFF0C;&#x4F1A;&#x4EA7;&#x751F;&#x65B0;&#x7684;&#x4E0A;&#x7EBF;&#x8BB0;&#x5F55;&#x3002;</p>
<h3 id="&#x6682;&#x505C;&#x4E0A;&#x7EBF;"><a name="&#x6682;&#x505C;&#x4E0A;&#x7EBF;" class="anchor-navigation-ex-anchor" href="#&#x6682;&#x505C;&#x4E0A;&#x7EBF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6682;&#x505C;&#x4E0A;&#x7EBF;</h3>
<p>&#x672C;&#x5C0F;&#x8282;&#x9700;&#x8981;&#x6C34;&#x5E73;&#x7F29;&#x653E;&#x3001;&#x6BD4;&#x4F8B;&#x7F29;&#x653E;&#x7B49;&#x77E5;&#x8BC6;&#xFF0C;&#x8BF7;&#x5148;&#x9605;&#x8BFB; 3.6 &#x7AE0;&#x5173;&#x4E8E;&#x7F29;&#x653E;&#x7684;&#x5185;&#x5BB9;&#x3002;</p>
<p>&#x5982;&#x679C;&#x5728;&#x4E0A;&#x7EBF;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x53D1;&#x73B0;&#x673A;&#x5668;&#x4E0D;&#x591F;&#x7528;&#x4E86;&#xFF0C;&#x6216;&#x8005;&#x9700;&#x8981;&#x8C03;&#x6574;&#x4E00;&#x4E9B;&#x914D;&#x7F6E;&#x7B49;&#xFF0C;&#x53EF;&#x4EE5;&#x6682;&#x505C;&#x4E0A;&#x7EBF;&#x8FC7;&#x7A0B;&#x3002;</p>
<p><code>kubectl rollout pause</code> &#x547D;&#x4EE4;&#x53EF;&#x4EE5;&#x8BA9;&#x6211;&#x4EEC;&#x5728; Deployment &#x7684; Pod &#x7248;&#x672C;&#x65F6;&#xFF0C;&#x6682;&#x505C;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x3002;</p>
<p>&#x547D;&#x4EE4;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl rollout pause deployment nginx
</code></pre>
<p>&#x5728;&#x6EDA;&#x52A8;&#x66F4;&#x65B0;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x4F1A;&#x6709;&#x4E00;&#x4E9B;&#x73B0;&#x8C61;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x7559;&#x610F;&#x3002;</p>
<p>&#x5148;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Deployment &#x6216;&#x8005;&#x66F4;&#x65B0; Deployment &#x7684; Pod &#x4E3A; 10 &#x4E2A;&#x526F;&#x672C;&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl create deployment --image<span class="token operator">=</span>nginx:1.19.0 --replicas<span class="token operator">=</span><span class="token number">10</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x6267;&#x884C; <code>kubectl edit deployment nginx</code> &#x4FEE;&#x6539;&#x7F29;&#x653E;&#x4E2A;&#x6570;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml">  <span class="token key atrule">strategy</span><span class="token punctuation">:</span>
    <span class="token key atrule">rollingUpdate</span><span class="token punctuation">:</span>
      <span class="token key atrule">maxSurge</span><span class="token punctuation">:</span> <span class="token number">3</span>
      <span class="token key atrule">maxUnavailable</span><span class="token punctuation">:</span> <span class="token number">2</span>
    <span class="token key atrule">type</span><span class="token punctuation">:</span> RollingUpdate
</code></pre>
<blockquote>
<p>&#x8BBE;&#x7F6E;&#x4E86;&#x8FD9;&#x4E2A; maxSurge &#x548C; maxUnavailable&#xFF0C;&#x53EF;&#x4EE5;&#x8BA9; Deployment &#x66FF;&#x6362; Pod &#x65F6;&#x6162;&#x4E00;&#x4E9B;&#x3002;</p>
</blockquote>
<p>&#x4E4B;&#x524D;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x4F7F;&#x7528;&#x4E86; <code>1.19.0</code>&#x3001;<code>1.20.0</code> &#x4E24;&#x4E2A;&#x7248;&#x672C;&#x8FDB;&#x884C;&#x6F14;&#x793A;&#xFF0C;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x4F7F;&#x7528; <code>latest</code> &#x7248;&#x672C;&#x8FDB;&#x884C;&#x5B9E;&#x8DF5;&#x3002;</p>
<p>&#x590D;&#x5236;&#x4EE5;&#x4E0B;&#x4E24;&#x6761;&#x547D;&#x4EE4;&#x5FEB;&#x901F;&#x6267;&#x884C;&#xFF0C;&#x53EF;&#x4EE5;&#x5FEB;&#x901F;&#x5361;&#x4F4F;&#x4E0A;&#x7EBF;&#x8FC7;&#x7A0B;&#x3002;&#x6211;&#x4EEC;&#x6682;&#x505C;&#x4E0A;&#x7EBF;&#x540E;&#xFF0C;&#x67E5;&#x770B;&#x4E00;&#x4E9B;&#x72B6;&#x6001;&#x4FE1;&#x606F;&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl <span class="token builtin class-name">set</span> image deployment nginx <span class="token assign-left variable">nginx</span><span class="token operator">=</span>nginx:latest
kubectl rollout pause deployment nginx
</code></pre>
<p>&#x6267;&#x884C; <code>kubectl get replicaset</code> &#x67E5;&#x770B;&#x8FD9;&#x4E9B;&#x7248;&#x672C;&#x7684;&#x6570;&#x91CF;&#x3002;</p>
<pre class="language-"><code class="lang-bash">NAME               DESIRED   CURRENT   READY   AGE
nginx-7b87485749   <span class="token number">8</span>         <span class="token number">8</span>         <span class="token number">8</span>       109m
nginx-85b45874d9   <span class="token number">0</span>         <span class="token number">0</span>         <span class="token number">0</span>       109m
nginx-bb957bbb5    <span class="token number">5</span>         <span class="token number">5</span>         <span class="token number">5</span>       52m
</code></pre>
<blockquote>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x6240;&#x6709;&#x7684; Pod &#x52A0;&#x8D77;&#x6765;&#x6570;&#x91CF;&#x5927;&#x4E8E; 10&#xFF0C;&#x65E7;&#x5BB9;&#x5668;&#x4EE5;&#x6BCF;&#x6B21; 2 &#x4E2A;&#x7684;&#x6570;&#x91CF;&#x51CF;&#x5C11;&#xFF1B;&#x65B0;&#x5BB9;&#x5668;&#x4EE5;&#x6BCF;&#x6B21; 3 &#x4E2A;&#x7684;&#x6570;&#x91CF;&#x521B;&#x5EFA;&#xFF1B;&#x6682;&#x505C;&#x4E0A;&#x7EBF;&#x540E;&#xFF0C;&#x591A;&#x6B21;&#x6267;&#x884C; <code>kubectl get replicaset</code> &#xFF0C;&#x4F1A;&#x53D1;&#x73B0;&#x526F;&#x672C;&#x6570;&#x91CF;&#x4E0D;&#x4F1A;&#x53D8;&#x5316;&#x3002;</p>
</blockquote>
<p>&#x524D;&#x9762;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x6682;&#x505C;&#x4E86;&#x4E0A;&#x7EBF;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x6267;&#x884C;&#x4E0A;&#x7EBF;&#x547D;&#x4EE4;&#x6362;&#x6210;&#x522B;&#x7684;&#x7248;&#x672C;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl <span class="token builtin class-name">set</span> image deployment nginx <span class="token assign-left variable">nginx</span><span class="token operator">=</span>nginx:1.19.0
</code></pre>
<p>&#x4F1A;&#x53D1;&#x73B0;&#x867D;&#x7136;&#x63D0;&#x793A;&#x66F4;&#x65B0;&#x4E86;&#xFF0C;&#x4F46;&#x662F;&#x5B9E;&#x9645;&#x4E0A;&#x6CA1;&#x6709;&#x53D8;&#x5316;&#x3002;&#x6267;&#x884C; <code>kubectl rollout history deployment nginx</code> &#x4E5F;&#x67E5;&#x4E0D;&#x5230;&#x6211;&#x4EEC;&#x63D0;&#x4EA4;&#x7684; <code>1.19.0</code> &#x7684;&#x8BF7;&#x6C42;&#x3002;&#x8FD9;&#x662F;&#x56E0;&#x4E3A;&#x5728;&#x5DF2;&#x7ECF;&#x6682;&#x505C;&#x4E0A;&#x7EBF;&#x7684;&#x63A7;&#x5236;&#x5668;&#x5BF9;&#x8C61;&#x4E2D;&#xFF0C;&#x6267;&#x884C;&#x65B0;&#x7684;&#x4E0A;&#x7EBF;&#x52A8;&#x4F5C;&#x662F;&#x65E0;&#x6548;&#x7684;&#x3002;</p>
<p>&#x6682;&#x505C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x66F4;&#x65B0;&#x4E00;&#x4E9B;&#x914D;&#x7F6E;&#xFF0C;&#x4F8B;&#x5982;&#x9650;&#x5236; Pod &#x4E2D;&#x7684; nginx &#x5BB9;&#x5668;&#x4F7F;&#x7528;&#x7684; CPU &#x548C; &#x8D44;&#x6E90;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl <span class="token builtin class-name">set</span> resources deployment nginx -c<span class="token operator">=</span>nginx --limits<span class="token operator">=</span>cpu<span class="token operator">=</span>200m,memory<span class="token operator">=</span>512Mi
</code></pre>
<p>&#x518D;&#x6062;&#x590D; Deployment &#x4E0A;&#x7EBF;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl rollout resume deployment nginx
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x75F4;&#x8005;&#x5DE5;&#x826F; 2021 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x6863;&#x6700;&#x540E;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2021-11-17 07:18:40
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="4.pod_network.html" class="navigation navigation-prev " aria-label="Previous page: 3.34 Pod 端口映射">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="6.scale.html" class="navigation navigation-next " aria-label="Next page: 3.6 Pod 缩放">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.5 Pod 升级、回滚","level":"1.4.6","depth":2,"next":{"title":"3.6 Pod 缩放","level":"1.4.7","depth":2,"path":"3.pod/6.scale.md","ref":"3.pod/6.scale.md","articles":[]},"previous":{"title":"3.34 Pod 端口映射","level":"1.4.5","depth":2,"path":"3.pod/4.pod_network.md","ref":"3.pod/4.pod_network.md","articles":[]},"dir":"ltr"},"config":{"plugins":["tbfed-pagefooter","anchor-navigation-ex","mermaid-gb3","insert-logo","chapter-fold","advanced-emoji","github","splitter","alerts","popup","prism","-highlight","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 痴者工良 2021","modify_label":"文档最后更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"prism":{"lang":{"flow":"typescript","shell":"bash"},"ignore":["mermaid","eval-js"],"css":["prismjs/themes/prism.css"],"js":["prismjs/prism.js","prismjs/components.js","prismjs/components/prism-go.min.js","prismjs/components/prism-yaml.min.js","prismjs/components/prism-bash.min.js","prismjs/components/prism-shell-session.min.js"]},"github":{"url":"https://github.com/whuanle/kubernetes"},"livereload":{},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":false,"showLevel":false},"alerts":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"insert-logo":{"style":"background: none; max-height: 50px; min-height: 50px","url":"/images/logo.jpg"}},"theme":"default","author":"痴者工良","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Kubernetes - 痴者工良","language":"zh-hans","links":{"sidebar":{"痴者工良的博客":"https://www.whuanle.cn"}},"gitbook":"*","description":"这是一本关于 Kubernetes 的书，作者 痴者工良"},"file":{"path":"3.pod/5.update.md","mtime":"2021-11-16T23:18:40.880Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-11-16T23:21:22.294Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

